package com.slipper.logger;

import ch.qos.logback.core.UnsynchronizedAppenderBase;
import ch.qos.logback.core.encoder.Encoder;
import com.slipper.core.message.MessageUtil;

public class WebConsoleAppender<E> extends UnsynchronizedAppenderBase<E> {
    protected Encoder<E> encoder;

    @Override
    protected void append(E event) {
        if (MessageUtil.isSubscribeLogger()) {
            byte[] byteArray = this.encoder.encode(event);
            MessageUtil.publishLogger(new String(byteArray));
        }
    }

    public Encoder<E> getEncoder() {
        return this.encoder;
    }

    public void setEncoder(Encoder<E> encoder) {
        this.encoder = encoder;
    }

}
